//
// Created by benxb on 2022/3/20.
//

#include "semantic_kitti_reader.h"
#include <common/timer.h>
#include <common/ini_reader.h>
#include <fstream>
#include <filesystem>
#include <iostream>

void SemanticKittiReader::ReadMapFile(std::vector<float>& x_arr, std::vector<float>& y_arr, std::vector<float>& z_arr,
                                      std::vector<uint16_t>& instance_arr, std::vector<uint16_t>& cls_arr) {
    // open data file
    data_io_.open(data_files_[next_index], std::ios::binary | std::ios::in | std::ios::out);
    while (!data_io_.eof()) {
        float x, y, z;
        uint16_t cls;
        uint16_t instance;
        data_io_.read(reinterpret_cast<char *>(&x), sizeof(x));
        data_io_.read(reinterpret_cast<char *>(&y), sizeof(y));
        data_io_.read(reinterpret_cast<char *>(&z), sizeof(z));
        data_io_.read(reinterpret_cast<char *>(&cls), sizeof(cls));
        data_io_.read(reinterpret_cast<char *>(&instance), sizeof(instance));
        x_arr.push_back(x);
        y_arr.push_back(z);
        z_arr.push_back(y);
        cls_arr.push_back(cls);
        instance_arr.push_back(instance);
    }
    next_index++;
    data_io_.close();
}

SemanticKittiReader::SemanticKittiReader(const std::string &data_dir) : DataReader(data_dir) {
}

void SemanticKittiReader::ReadSweep(std::vector<float> &x_arr, std::vector<float> &y_arr, std::vector<float> &z_arr) {

}
